/**
 * @Title: HomeActivity.java
 * @Package com.sinoglobal.waitingMe.activity
 * @Description: TODO(用一句话描述该文件做什么)
 * @author hpq
 * @date 2015-8-30 上午11:55:09
 */

package com.sinoglobal.wallet.activity;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationSet;
import android.view.animation.AnimationUtils;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.alipay.sdk.app.PayTask;
import com.sinoglobal.wallet.R;
import com.sinoglobal.wallet.api.RemoteImpl;
import com.sinoglobal.wallet.app.SinoConstans;
import com.sinoglobal.wallet.app.SinoValueManager;
import com.sinoglobal.wallet.entity.RsAplipay;
import com.sinoglobal.wallet.entity.RsUpay;
import com.sinoglobal.wallet.entity.RsWechat;
import com.sinoglobal.wallet.entity.W_AlipayEntiy;
import com.sinoglobal.wallet.entity.W_OrderStateEntiy;
import com.sinoglobal.wallet.entity.W_UpayEntiy;
import com.sinoglobal.wallet.entity.W_WechatEntiy;
import com.sinoglobal.wallet.task.MyAsyncTask;
import com.sinoglobal.wallet.util.ActivityUtil;
import com.sinoglobal.wallet.util.LogUtils;
import com.sinoglobal.wallet.util.NetWorkUtil;
import com.sinoglobal.wallet.util.PayResult;
import com.sinoglobal.wallet.util.TextUtil;
import com.sinoglobal.wallet.util.ValidUtil;
//import com.sinoglobal.wallet.wxapi.WXPayEntryActivity.WechatReciver;
import com.tencent.mm.sdk.constants.Build;
import com.tencent.mm.sdk.modelpay.PayReq;
import com.tencent.mm.sdk.openapi.IWXAPI;
import com.tencent.mm.sdk.openapi.WXAPIFactory;
import com.umpay.quickpay.UmpPayInfoBean;
import com.umpay.quickpay.UmpayQuickPay;

/**
 * @author clf
 * @createdate 2015-10-22
 * @Description: TODO(余额明细)
 */
public class W_RechargelActivity extends W_SinoBaseActivity {
	private TextView recharge_commit,recharge_pay_style_text;
	   public View view1;
	private RelativeLayout pay_fu_bao_layout, pay_weChat_layout,cash_card_layout,recharge_pay_style;
	private ImageView pay_fu_bao_img,pay_weChat_img,cash_card_img;
	private int payStyle=0;//支付方式标识
	private PopupWindow mpopupWindow;
	private LinearLayout ll_popup;
	private AnimationSet outAnimationSet;
	private EditText recharge_num;
	private String str="";//金额数目
	private InputMethodManager imm;
	private RsAplipay aplipay;//获取的支付宝订单对象
	private RsUpay upay;//获取的U付订单对象
	  private static final int SDK_PAY_FLAG = 1; //支付宝支付用的判断标记
	private MyHandler myHandler;//支付宝支付信息回调 使用静态内部类是防止内存泄露
	private String isRecharge="-1";//1,充值成功。0，充值失败。2待充值,3.提交成功
	private String Type="1";//充值界面跳转到充值详情的标示1是充值界面跳过去。2是充值记录界面跳过去
	private boolean isSelectPayStyle = false;
	private String orderSn="";//支付模块请求的订单参数。如果有则 不生成新订单（可对旧订单做更新）。没有则生成新订单；
	/** 请求返回码 **/
	public static final int REQUESTCODE = 1;
	/** 优付支付成功 **/
	private static final String UMPAY_SUCCESS = "0000";
	/** 优付支付取消 **/
	private static final String UMPAY_CANCEL = "1001";
	private IWXAPI api;
//	private WechatReciver weChatReciver;
	private class MyHandler extends Handler {


        public void handleMessage(Message msg) {
            switch (msg.what) {
                case SDK_PAY_FLAG: {
                    PayResult payResult = new PayResult((String) msg.obj);

                    // 支付宝返回此次支付结果及加签，建议对支付宝签名信息拿签约时支付宝提供的公钥做验签
                    String resultInfo = payResult.getResult();
                    //支付状态
                    String resultStatus = payResult.getResultStatus();
                //	Toast.makeText(W_RechargelActivity.this, "支付宝返回码=="+resultStatus, 0).show();
                    // 判断resultStatus 为“9000”则代表支付成功，具体状态码代表含义可参考接口文档
                    if (TextUtils.equals(resultStatus, "9000")) {
                       // notifyServer();通知故服务器支付成功
                        showToast(getString(R.string.pay_success));
                    	isRecharge="1";
                    	getOrderState(aplipay.getTrade_sn());	
                    	break;
                    }
                    // 判断resultStatus 为非“9000”则代表可能支付失败
                    // “8000”代表支付结果因为支付渠道原因或者系统原因还在等待支付结果确认，最终交易是否成功以服务端异步通知为准（小概率状态）
                    else if (TextUtils.equals(resultStatus, "8000")) {
                       // showToast(getString(R.string.pay_confirming));
                      	isRecharge="3";
            			
                    } else if (TextUtils.equals(resultStatus, "6001")) {
                     //   showToast(getString(R.string.pay_confirming));
                      	isRecharge="2";
            			
                    } else if (TextUtils.equals(resultStatus, "6002")) {
                       // showToast(getString(R.string.pay_confirming));
                        Toast.makeText(W_RechargelActivity.this, "网络状态不佳，请稍侯！", 0).show();
            			return;
                    }else {
                        // 其他值就可以判断为支付失败，包括用户主动取消支付，或者系统返回的错误
                        showToast(getString(R.string.pay_fail));
                    	isRecharge="0";
                    }
                    Bundle bundle = new Bundle();
        			bundle.putString("isRecharge", isRecharge);
        			bundle.putString("Money", str);
        			bundle.putSerializable("Sing", aplipay);//支付宝签名
        			 bundle.putInt("payStyle", payStyle);
        			goIntent(W_RechargeDetailsActivity.class, bundle); 	
                    break;
                }
            }
        }
    }
	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		setContentView(R.layout.wallet_recharge_layout);
		api = WXAPIFactory.createWXAPI(this, null);
		// 将该app注册到微信
		api.registerApp(SinoConstans.APP_WeCHATID);
		mTemplateTitleText.setText("充值");
		showView(mTemplateRightText);
		mTemplateRightText.setText("记录");
		mTemplateRightText.setOnClickListener(this);
		initView();
		initpopView();
		String paystyle = (String) SinoValueManager.getValue(this, "payStyle","");
		if(paystyle!=null){
			   if("2".equals(paystyle)){
				   isSelectPayStyle=true;
					  pay_fu_bao_img.setVisibility(View.VISIBLE);
				        pay_weChat_img.setVisibility(View.GONE);
				        cash_card_img.setVisibility(View.GONE);
				        payStyle=2;
					recharge_pay_style_text.setText("支付宝");
				}else if("3".equals(paystyle)){
					isSelectPayStyle=true;
					 pay_fu_bao_img.setVisibility(View.GONE);
				        pay_weChat_img.setVisibility(View.GONE);
				        cash_card_img.setVisibility(View.VISIBLE);
				        payStyle=3;
					recharge_pay_style_text.setText("借记卡");
				}else if("4".equals(paystyle)){
					isSelectPayStyle=true;
					 pay_fu_bao_img.setVisibility(View.GONE);
				        pay_weChat_img.setVisibility(View.VISIBLE);
				        cash_card_img.setVisibility(View.GONE);
				        payStyle=4;
					recharge_pay_style_text.setText("微信支付");
				}		
			
		}
		
		
	}
	private void initView() {
          myHandler=new MyHandler();
		imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
		recharge_pay_style_text = (TextView) findViewById(R.id.recharge_pay_style_text);
		recharge_num = (EditText) findViewById(R.id.recharge_num);
		recharge_commit = (TextView) findViewById(R.id.recharge_commit);
		recharge_pay_style = (RelativeLayout) findViewById(R.id.recharge_pay_style);
		recharge_commit.setOnClickListener(this);
		recharge_pay_style.setOnClickListener(this);
		recharge_num.addTextChangedListener(new TextWatcher() {
			@Override
			public void onTextChanged(CharSequence s, int start, int before, int count) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void beforeTextChanged(CharSequence s, int start, int count,
					int after) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void afterTextChanged(Editable s) {
				// TODO Auto-generated method stub
				str=s.toString().trim();
				if(str.indexOf(".") != -1){  
		             //获取小数点的位置  
		             int num = 0;  
		             num = str.indexOf(".");  
		               
		             //获取小数点后面的数字 是否有两位 不足两位补足两位  
		             String dianAfter = str.substring(0,num+1);  
		             String afterData = str.replace(dianAfter, "");  
		            if(afterData.length()>=3){
		            	String  data=str.substring(0,num) + "." + afterData.substring(0,2);
		             recharge_num.setText(data)  ; 
		             recharge_num.setSelection(data.length());}
			}
			}
		});	
	}
	/**
     * 初始化popwindow
     */
    public void initpopView() {
        // popwindow相关控件的初始化
        view1 = View.inflate(this, R.layout.wallet_pay_popu_list_layout, null);
        ll_popup = (LinearLayout) view1.findViewById(R.id.pay_popu_layout);
       pay_fu_bao_layout = (RelativeLayout) view1.findViewById(R.id.pay_fu_bao_layout);
        pay_weChat_layout = (RelativeLayout) view1.findViewById(R.id.pay_weChat_layout);
        cash_card_layout = (RelativeLayout) view1.findViewById(R.id.cash_card_layout);
        pay_fu_bao_img = (ImageView) view1.findViewById(R.id.pay_fu_bao_img);
        pay_weChat_img = (ImageView) view1.findViewById(R.id.pay_weChat_img);
        cash_card_img = (ImageView) view1.findViewById(R.id.cash_card_img);
       pay_fu_bao_layout.setOnClickListener(this);
        pay_weChat_layout.setOnClickListener(this);
        cash_card_layout.setOnClickListener(this);
        view1.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {

                mpopupWindow.dismiss();
            }
        });

    }

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		int id = v.getId();
		if(id==R.id.recharge_commit){
			
			if (!validNumber(str).equals("")) {
				Toast.makeText(this, validNumber(str), 0).show();
				return;
			}
			if ("".equals(str)) {
				showDialog(W_RechargelActivity.this, "提示", "充值金额不能为空！", "", R.color.w_c7, "", R.color.w_c14, false,
						new DialogOnClickListener() {

							@Override
							public void onSure(View v) {
							}

							@Override
							public void onCancle(View v) {
							}
						});
				return;
			}
			if (Double.valueOf(str) == 0) {
				showDialog(W_RechargelActivity.this, "提示", "充值额为0，请重新输入金额", "", R.color.w_c7, "", R.color.w_c14, false,
						new DialogOnClickListener() {

							@Override
							public void onSure(View v) {
							}

							@Override
							public void onCancle(View v) {
							}
						});
				return;
			}
			if (!validNumber(str).equals("")) {
				Toast.makeText(this, ValidUtil.validNumber(str), 0).show();
				return;
			}
			if (!isSelectPayStyle) {
				showToast("请选择支付方式！");
				return;
			}
			
		if(payStyle==2){
			getAlipayData();
		}else if(payStyle==3){
			getUpayData();
		}else if(payStyle==4){
		
			boolean isPaySupported = api.getWXAppSupportAPI() >= Build.PAY_SUPPORTED_SDK_INT;
		
			if(ActivityUtil.checkApkExist(this,"com.tencent.mm")){
				if(isPaySupported){
					getWechatData();
				}else{
					Toast.makeText(this, "当前微信版本不支持支付！", 0).show();
				}
			
			}else{
				Toast.makeText(this, "请先安装微信！", 0).show();
			}
			
		
		}
			
			
		}else if(id==R.id.recharge_pay_style){
			imm.hideSoftInputFromWindow(recharge_commit.getWindowToken(), 0);
		    ll_popup.startAnimation(AnimationUtils.loadAnimation(getApplicationContext(), R.anim.w_push_bottom_in));
		    if (mpopupWindow == null) {
		        mpopupWindow = new PopupWindow(this);
		        mpopupWindow.setWidth(LayoutParams.MATCH_PARENT);
		        mpopupWindow.setHeight(LayoutParams.MATCH_PARENT);
		        mpopupWindow.setBackgroundDrawable(new BitmapDrawable());
		        mpopupWindow.setFocusable(true);
		        mpopupWindow.setOutsideTouchable(true);
		    }
		    mpopupWindow.setContentView(view1);
		    mpopupWindow.showAtLocation(recharge_pay_style, Gravity.BOTTOM, 0, 0);
		    mpopupWindow.update();
		}else if(id==R.id.pay_fu_bao_layout){
			isSelectPayStyle=true;
			  pay_fu_bao_img.setVisibility(View.VISIBLE);
		        pay_weChat_img.setVisibility(View.GONE);
		        cash_card_img.setVisibility(View.GONE);
		        payStyle=2;
		        recharge_pay_style_text.setText("支付宝");
		        SinoValueManager.putValue(this, "payStyle", "2", true);
		        popuDismiss();
		}else if(id==R.id.pay_weChat_layout){
			isSelectPayStyle=true;
			 pay_fu_bao_img.setVisibility(View.GONE);
		        pay_weChat_img.setVisibility(View.VISIBLE);
		        cash_card_img.setVisibility(View.GONE);
		        payStyle=4;
		        SinoValueManager.putValue(this, "payStyle", "4", true);
		        recharge_pay_style_text.setText("微信支付");
		        popuDismiss();
		}else if(id==R.id.cash_card_layout){
			isSelectPayStyle=true;
			 pay_fu_bao_img.setVisibility(View.GONE);
		        pay_weChat_img.setVisibility(View.GONE);
		        cash_card_img.setVisibility(View.VISIBLE);
		        payStyle=3;
		        SinoValueManager.putValue(this, "payStyle", "3", true);
		        recharge_pay_style_text.setText("借记卡");
		        popuDismiss();
		}else if(id==R.id.wallet_title_right_tv){
		goIntent(W_RechargeRecordActivity.class);
	}else if (id == R.id.wallet_noData) {
		 if(NetWorkUtil.getNetWorkInfoType(getApplicationContext())==NetWorkUtil.NONE){
				showToast("请检查网络是否连接！");	
				 loadError(true);
				}else{
					loadError(false);;
				}
	}
	}
	private void popuDismiss() {
		Animation Animation = AnimationUtils.loadAnimation(this,R.anim.w_push_bottom_out);
		ll_popup.startAnimation(Animation);
		Animation.setAnimationListener(new AnimationListener() {
			@Override
			public void onAnimationStart(Animation animation) {
			}
			@Override
			public void onAnimationRepeat(Animation animation) {
			}
			@Override
			public void onAnimationEnd(Animation animation) {
				 // LogUtils.v(  "mpopupWindow.dismiss();---------");
				   mpopupWindow.dismiss();
			}
		});
	}
	private void getAlipayData() {
		MyAsyncTask<W_AlipayEntiy> task = new MyAsyncTask<W_AlipayEntiy>(true,this,true) {
			@Override
			public W_AlipayEntiy before(Void... params) throws Exception {
				// TODO 测试接口
				return RemoteImpl.getInstance().getAlipay(W_RechargelActivity.this, orderSn,str, "钱包充值", "钱包", "1", "wallet");
			}

			@Override
			public void after(W_AlipayEntiy result) {
				if (result != null) {
					if (result.getCode().equals("100")) {
				orderSn="";//订单设置为空;
					aplipay=result.getRs();
					pay(aplipay.getSign());
					}else{
						orderSn=result.getRs().getTrade_sn();
						Toast.makeText(W_RechargelActivity.this, result.getMsg(), 0).show();
					}
				}

			}

			@Override
			public void exception() {
			}
		};
		task.execute();
	}
	private void getUpayData() {
		MyAsyncTask<W_UpayEntiy> task = new MyAsyncTask<W_UpayEntiy>(true,this,true) {
			@Override
			public W_UpayEntiy before(Void... params) throws Exception {
				// TODO 测试接口
				return RemoteImpl.getInstance().getUpay(W_RechargelActivity.this, orderSn,str, "钱包充值", "钱包", "1", "wallet");
			}
			
			@Override
			public void after(W_UpayEntiy result) {
				if (result != null) {
					if (result.getCode().equals("100")) {
						  orderSn="";//订单设置为空;
						upay=result.getRs();
						//LogUtils.v("rs.getTrade_no()===="+	upay.getTrade_no());
						doUmpay(upay.getTrade_no());
					}else{
						
						orderSn=result.getRs().getTrade_sn();
						Toast.makeText(W_RechargelActivity.this, result.getMsg(), 0).show();
					}
				}
				
			}
			
			@Override
			public void exception() {
			}
		};
		task.execute();
	}
	private void getWechatData() {
		MyAsyncTask<W_WechatEntiy> task = new MyAsyncTask<W_WechatEntiy>(true,this,true) {
			@Override
			public W_WechatEntiy before(Void... params) throws Exception {
				// TODO 测试接口
				return RemoteImpl.getInstance().getWeChat(W_RechargelActivity.this, orderSn,str, "钱包充值", "钱包", "1", "wallet");
			}
			
			@Override
			public void after(W_WechatEntiy result) {
				if (result != null) {
					if (result.getCode().equals("100")) {
						    orderSn="";//订单设置为空;
							RsWechat wechat=result.getRs();
							PayReq req = new PayReq();
							req.appId			= wechat.getAppId();
							req.partnerId		= wechat.getPartnerid();
							req.prepayId		= wechat.getPrepayid();
							req.nonceStr		= wechat.getNoncestr();
							req.timeStamp		= wechat.getTimestamp();
							req.packageValue	="Sign=WXPay";
							 req.sign			= wechat.getSign();
						//	LogUtils.v("appId=="+	req.appId+"partnerId=="+req.partnerId+"prepayId=="+req.prepayId+"nonceStr=="+req.nonceStr+"timeStamp=="+req.timeStamp+"packageValue=="+req.packageValue+"sign==="+req.sign	);
							// 在支付之前，如果应用没有注册到微信，应该先调用IWXMsg.registerApp将应用注册到微信
							api.sendReq(req);//这句代码如果调用多次就会出现多个支付页面。别乱写哦！
							sendWeChatBroadcast(wechat,str,"wallet");//传到微信的回调页面WXPayEntryActivity
					}else{
						orderSn=result.getRs().getTrade_sn();
						Toast.makeText(W_RechargelActivity.this, result.getMsg(), 0).show();
					}
				}
				
			}
			
			@Override
			public void exception() {
			}
		};
		task.execute();
	}
	/**
	 * 
	 * @param orderSn查询订单状态
	 */
	private void getOrderState(final String orderSn) {
		MyAsyncTask<W_OrderStateEntiy> task = new MyAsyncTask<W_OrderStateEntiy>(true,this,true) {
			@Override
			public W_OrderStateEntiy before(Void... params) throws Exception {
				// TODO 测试接口
				return RemoteImpl.getInstance().getOrderState(W_RechargelActivity.this,orderSn);
			}
			
			@Override
			public void after(W_OrderStateEntiy result) {
				if (result != null) {
					if (result.getCode().equals("100")) {
						 String  orderState=result.getRs();
						 if("3".equals(orderState)){//支付订单状态1：支付中、2：已回调、3：支付成功、4：异常订单
								isRecharge="1";
						  }else {
								isRecharge="3";
						  }
						 Bundle bundle = new Bundle();
		        			bundle.putString("isRecharge", isRecharge);
		        			bundle.putString("Money", str);
		        			 bundle.putInt("payStyle", payStyle);
		        			 bundle.putSerializable("Sing", aplipay);//支付宝签名
		        			 bundle.putSerializable("Upay", upay);//支付宝签名
		        			goIntent(W_RechargeDetailsActivity.class, bundle);
					}else{
						Toast.makeText(W_RechargelActivity.this, result.getMsg(), 0).show();
						 Bundle bundle = new Bundle();
		        			bundle.putString("isRecharge", isRecharge);
		        			bundle.putString("Money", str);
		        			 bundle.putInt("payStyle", payStyle);
		        			 bundle.putSerializable("Sing", aplipay);//支付宝签名
		        			 bundle.putSerializable("Upay", upay);//支付宝签名
		        			goIntent(W_RechargeDetailsActivity.class, bundle);
					}
				}
				
			}
			
			@Override
			public void exception() {
			}
		};
		task.execute();
	}

	private void sendWeChatBroadcast(RsWechat rs,String str,String type) {
		Intent intent = new Intent();
		intent.setAction(SinoConstans.KEY_WechatReceiver);
		intent.putExtra("WeChat",rs);
		intent.putExtra("Money",str);
		intent.putExtra("Type",type);
		sendBroadcast(intent);
	}
    /**
     * U付支付
     *
     * @param tradeNo 封装数据
     */
    private void doUmpay(String tradeNo) {
        UmpayQuickPay.requestPayWithBind(this, tradeNo, null, "0", null, new UmpPayInfoBean(), REQUESTCODE);//借记卡支付
    }
	/**
	 * call alipay sdk pay. 调用SDK支付
	 * 
	 */
	public void pay(final String orderInfo) {
		Runnable payRunnable = new Runnable() {
			@Override
			public void run() {
				// 构造PayTask 对象
				PayTask alipay = new PayTask(W_RechargelActivity.this);
				// 调用支付接口
				String result = alipay.pay(orderInfo);
				Message msg = new Message();
				msg.what = SDK_PAY_FLAG;
				msg.obj = result;
				myHandler.sendMessage(msg);
			}
		};
		   // 必须异步调用
        Thread payThread = new Thread(payRunnable);
        payThread.start();

		 
	}
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		  if (myHandler != null) { //退出时清空handler所有队列信息,以防内存泄露
	            myHandler.removeCallbacksAndMessages(null);
	        }
	}
	/**
	 * 3.U付在这里接收并处理支付结果
	 * 
	 * @param requestCode
	 *            支付请求码
	 * @param resultCode
	 *            SDK固定返回88888
	 * @param data
	 *            支付结果和结果描述信息
	 * @author niexuyang 2012-8-20
	 */
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		if (requestCode == REQUESTCODE) {
			String umpresultCode = data.getStringExtra("umpResultCode");
			if (UMPAY_SUCCESS.equals(umpresultCode)) {
				//showToast("支付成功");
				isRecharge="1";
            	getOrderState(upay.getTrade_sn());	
            	
			} else if (UMPAY_CANCEL.equals(umpresultCode)) {
				showToast("取消支付");
				isRecharge="2";
				  Bundle bundle = new Bundle();
      			bundle.putString("isRecharge", isRecharge);
      			bundle.putString("Money", str);
      			bundle.putSerializable("Upay", upay);//U付订单对象
      			 bundle.putInt("payStyle", payStyle);
      			goIntent(W_RechargeDetailsActivity.class, bundle); 	
			} else {
				showToast("支付失败");
				isRecharge="0";
				  Bundle bundle = new Bundle();
      			bundle.putString("isRecharge", isRecharge);
      			bundle.putString("Money", str);
      			 bundle.putInt("payStyle", payStyle);
      			bundle.putSerializable("Upay", upay);//U付订单对象
      			goIntent(W_RechargeDetailsActivity.class, bundle); 	
			}
			super.onActivityResult(requestCode, resultCode, data);
		}
	}
	public static String validNumber(String trainNumber) {
		String message = "";
		String rule;
		if (TextUtil.stringIsNotNull(trainNumber)) {
			// 其他证件只能输入数字、和小数
			rule = "^[0-9]+|^(\\d+(\\.\\d{1,2})?)?$";
			Matcher match = Pattern.compile(rule).matcher(trainNumber);
			if (!match.matches()) {
				message = "请输入正确的金额！";
			}
		} else {
			message = "请输入充值金额";
		}
		return message;
	}
}
